﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class login : System.Web.UI.Page
{
    public OleDbConnection myConnection;
    public static readonly string sConnectionString = System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString();
    protected void Page_Load(object sender, EventArgs e)
    {
        myConnection = new OleDbConnection(sConnectionString);
        myConnection.Open();
       
            Session["UserNo"] = null;
            Session["UserName"] = null;

    }

    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        {
            string mysql = "select * from ManagerTb where Dno='" + UserNo.Text.Trim() + "'and Dpass='" + UserPass.Text.Trim() + "'  ";
            OleDbCommand mycmd = new OleDbCommand(mysql, myConnection);
            OleDbDataReader myReader = mycmd.ExecuteReader();
            if (myReader.Read())
            {
                Session["UserNo"] = UserNo.Text.Trim();//保存账号
                Session["UserName"] = myReader[2].ToString();//保存姓名
                Response.Redirect("adminstrator/adminMenu.aspx");//跳转到管理员页面
            }
            else
                LabelError.Text = "*您输入工号或密码有误，请重新输入！";
        }
    }
}







